Source code for /engineering/webperf/slave-v4[j1.2]/ObjectMonitor.java | Original file ObjectMonitor.java |
1 public class ObjectMonitor extends Object { 2 private int locked; 3 4 public ObjectMonitor() { 5 this(1); 6 } 7 8 public ObjectMonitor(int lock) { 9 locked = lock; 10 } 11 12 public synchronized void lock(boolean lock) { 13 if (lock) { 14 while (locked == 0) { 15 try { 16 wait(); 17 } catch (InterruptedException e) { 18 } 19 } 20 locked--; 21 } else { 22 locked++; 23 notify(); 24 } 25 } 26 } 27 |
Copyright (C) 2009,2010,2018 Erich P Gatejen All rights reserved. | Generated by RendSite 2009 |